package com.train.system.api;

import com.train.common.resp.CommonResp;
import com.train.system.dto.train.TrainPageDTO;
import com.train.system.resp.train.TrainListResp;
import com.train.system.resp.train.TrainPageResp;
import com.train.system.service.TrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TrainApiImpl implements TrainApi {

    @Autowired
    private TrainService trainService;

    @Override
    public CommonResp getTrainList(TrainPageDTO trainPageDTO) {
        List<TrainPageResp> trainList = trainService.getTrainList(trainPageDTO);
        return CommonResp.ok(trainList);
    }

    @Override
    public CommonResp validTrainCodeList(String trainCode) {
        trainService.validTrainCode(trainCode);
        return CommonResp.ok();
    }

    @Override
    public CommonResp getTrainListByTrainCodes(List<String> trainCodes) {
        List<TrainListResp> trainListRespList = trainService.getTrainListByTrainCodes(trainCodes);
        return CommonResp.ok(trainListRespList);
    }
}
